package com.hxit.contorller;
import com.hxit.pojo.PageBean;
import com.hxit.pojo.Result;
import com.hxit.pojo.SystemLogs;
import com.hxit.servics.SystemLogsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName SystemLogsController
 * @Author 12694
 * @Date 2024/11/4 21:31
 * @Version 1.0
 **/
@RestController
@Slf4j
public class SystemLogsController<Integer> {
    @Autowired
    private SystemLogsService systemLogsService;
    //添加系统日志
    @PostMapping("/insertSystemLogs")
    public Result insertSystemLogs(@RequestBody SystemLogs systemLogs){
        systemLogsService.insertSystemLogs(systemLogs);
        log.info("添加日志");
        return Result.success();
    }
    //查询系统日志
    @GetMapping("/selectSystemLogsPage")
    public Result selectSystemLogsPage(@RequestParam(defaultValue = "1") java.lang.Integer page,
                                       @RequestParam(defaultValue = "10") java.lang.Integer pageSize){
        log.info("分页查询：",page,pageSize);
        PageBean pageBean=systemLogsService.selectSystemLogsPage(page,pageSize);
        return Result.success(pageBean);
    }
    //根据id查询日志
    @GetMapping("/selectSystemLogsById/{id}")
    public Result selectSystemLogsById(@PathVariable java.lang.Integer id){
        SystemLogs systemLogs = systemLogsService.selectSystemLogsById(id);
        log.info("根据id查询日志{}",systemLogs);
        return Result.success(systemLogs);
    }
    //修改日志信息
    @PutMapping("/updateSystemLogs")
    public Result updateSystemLogs(@RequestBody SystemLogs systemLogs){
        systemLogsService.updateSystemLogs(systemLogs);
        log.info("修改日志");
        return Result.success();
    }
    //删除日志信息
    @DeleteMapping("/deleteSystemLogs/{ids}")
    public Result deleteSystemLogs(@PathVariable List<java.lang.Integer> ids){
        systemLogsService.deleteSystemLogs(ids);
        log.info("删除日志");
        return Result.success();
    }
}
